Geographic Projections & Features
In this tutorial, you’ll learn about:
Selecting Projections & Features for UXarray plots
Related Documentation
Prerequisites
Time to learn: 5 minutes
import cartopy.crs as ccrs
import uxarray as ux
grid_path = "../../meshfiles/oQU480.grid.nc"
data_path = "../../meshfiles/oQU480.data.nc"
uxds = ux.open_dataset(grid_path, data_path)
Projections
Projections can be be selected by
projection = ccrs.Orthographic()
projection
<cartopy.crs.Orthographic object at 0x7f43e3ae2740>
uxds["bottomDepth"].plot.polygons(projection=projection)
projection = ccrs.Orthographic(central_longitude=-180)
projection
<cartopy.crs.Orthographic object at 0x7f43d7ce7be0>
uxds["bottomDepth"].plot.polygons(projection=projection)
Features
Geographic features can be added to plots using hvPlot’s interface to GeoViews. Available features include ‘borders’, ‘coastline’, ‘lakes’, ‘land’, ‘ocean’, ‘rivers’ and ‘states’.
uxds["bottomDepth"].plot.polygons(
projection=projection, features=["borders", "coastline"]
)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/110m_cultural/ne_110m_admin_0_boundary_lines_land.zip
warnings.warn(f'Downloading: {url}', DownloadWarning)
The scale of each feature can also be controlled by passing in a dictionary of features and the scale to the features parameter. Avaliable scales include ‘10m’, ‘50m’ and ‘110m’
uxds["bottomDepth"].plot.polygons(
projection=projection, features={"borders": "10m", "coastline": "10m"}
)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_coastline.zip
warnings.warn(f'Downloading: {url}', DownloadWarning)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_cultural/ne_10m_admin_0_boundary_lines_land.zip
warnings.warn(f'Downloading: {url}', DownloadWarning)